﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Kojarskiy.Models;
using SiteMap = Kojarskiy.Models.SiteMap;

namespace Kojarskiy.Core
{
    public class SearchHelper
    {
        public static List<SiteMap> FindPages(string searchString, KojarskiyDbEntities context)
        {
            List<SiteMap> result;
            if (!string.IsNullOrEmpty(searchString))
            {
                result = context.SiteMap.Search(searchString, x => x.Title, x => x.Description, x => x.Keywords, x => x.Content, x => x.PageName).ToList<SiteMap>();
                return result;
            }
            return new List<SiteMap>();
        }
        public static List<News> FindNews(string searchString, KojarskiyDbEntities context)
        {
            List<News> result;
            if (!string.IsNullOrEmpty(searchString))
            {
                result = context.News.Search(searchString, x => x.Name, x => x.Content, x => x.Title, x => x.Description, x => x.Keywords).ToList<News>();
                return result;
            }
            return new List<News>();
        }
    }
}